package com.lb.shopguide.ui.fragment.guide.order;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.Editable;
import android.text.InputFilter;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.View;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.blankj.utilcode.util.KeyboardUtils;
import com.blankj.utilcode.util.ToastUtils;
import com.lb.baselib.http.ResponseCode;
import com.lb.baselib.http.SimpleLbObserver;
import com.lb.baselib.http.bean.BaseResponse;
import com.lb.shopguide.R;
import com.lb.shopguide.adapter.AdapterGoodsInSureOrder;
import com.lb.shopguide.base.BaseCommonFragment;
import com.lb.shopguide.config.UserConfigManager;
import com.lb.shopguide.constants.AppConstant;
import com.lb.shopguide.entity.ChooseMemberBean;
import com.lb.shopguide.entity.CouponBean;
import com.lb.shopguide.entity.order.CommitGoodsBean;
import com.lb.shopguide.entity.order.CommitOrderBean;
import com.lb.shopguide.entity.order.CommitOrderReplyBean;
import com.lb.shopguide.entity.order.ConfirmOrderBean;
import com.lb.shopguide.entity.order.ConfirmOrderReplyBean;
import com.lb.shopguide.entity.order.GoodsInSureOrderBean;
import com.lb.shopguide.event.guide.SelectCouponEvent;
import com.lb.shopguide.event.guide.SelectMemberEvent;
import com.lb.shopguide.http.method.ApiMethodGuide;
import com.lb.baselib.http.SimpleObserverOnNextListener;
import com.lb.baselib.http.SimpleObserverOtherListener;
import com.lb.shopguide.ui.activity.PayActivity;
import com.lb.shopguide.ui.fragment.guide.FragmentMain;
import com.lb.shopguide.ui.fragment.guide.member.FragmentSelectMember;
import com.lb.shopguide.ui.fragment.guide.pay.FragmentPayResult;
import com.lb.shopguide.ui.view.EditInputFilter;
import com.lb.shopguide.ui.view.NormalTitleBar;
import com.lb.shopguide.util.json.JsonUtil;
import com.lb.shopguide.util.lb.BizUtil;
import com.lb.shopguide.util.lb.ClickUtil;
import com.trello.rxlifecycle2.android.FragmentEvent;
import com.yqritc.recyclerviewflexibledivider.HorizontalDividerItemDecoration;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;
import okhttp3.RequestBody;

/**
 * Created by kang on 2017/6/2.
 */

public class FragmentSureOrder extends BaseCommonFragment implements CompoundButton.OnCheckedChangeListener {
    @BindView(R.id.ntb)
    NormalTitleBar ntb;
    @BindView(R.id.recyclerView)
    RecyclerView mRecyclerView;
    @BindView(R.id.rl_ali_pay)
    RelativeLayout layoutAliPay;
    @BindView(R.id.rl_wechat_pay)
    RelativeLayout layoutWechatPay;
    @BindView(R.id.rl_cash_pay)
    RelativeLayout layoutCashPay;
    @BindView(R.id.rl_balance_pay)
    RelativeLayout layoutBalancePay;
    @BindView(R.id.layout_member)
    RelativeLayout layoutMember;
    @BindView(R.id.layout_ticket)
    RelativeLayout layoutTicket;
    @BindView(R.id.layout_quick_pay)
    LinearLayout layoutQuickPay;
    @BindView(R.id.et_pay_money)
    EditText etPayMoney;
    @BindView(R.id.tv_select_member)
    TextView tvSelectMember;
    @BindView(R.id.tv_select_ticket)
    TextView tvSelectTicket;
    @BindView(R.id.chk_ali_pay)
    CheckBox chkAliPay;
    @BindView(R.id.chk_wechat_pay)
    CheckBox chkWechatPay;
    @BindView(R.id.chk_cash_pay)
    CheckBox chkCashPay;
    @BindView(R.id.chk_balance_pay)
    CheckBox chkBalancePay;
    @BindView(R.id.tv_price_discount)
    TextView tvDiscount;
    @BindView(R.id.et_beizhu)
    EditText etBeizhu;
    @BindView(R.id.tv_do_order)
    TextView tvDoOrder;
    @BindView(R.id.tv_price_total)
    TextView tvTotalPrice;

    private AdapterGoodsInSureOrder mAdapterGoodsInSureOrder;
    private ChooseMemberBean mChooseMemberBean;
    private CouponBean mCouponBean;
    private ConfirmOrderReplyBean mConfirmOrderReplyBean;

    private int checkPos = -1;
    private int checkMode = AppConstant.NORMAL_CHECKOUT;//分为快速收银和正常收银

    public static FragmentSureOrder newInstance(String info) {
        FragmentSureOrder fragmentSureOrderFromCheckout = new FragmentSureOrder();
        Bundle bundle = new Bundle();
        bundle.putString(AppConstant.CONFIRM_ORDER_REPLY_INFO, info);
        bundle.putInt(AppConstant.SURE_ORDER_MODE, AppConstant.NORMAL_CHECKOUT);
        fragmentSureOrderFromCheckout.setArguments(bundle);
        return fragmentSureOrderFromCheckout;
    }


    public static FragmentSureOrder newInstance() {
        FragmentSureOrder fragmentSureOrderFromCheckout = new FragmentSureOrder();
        Bundle bundle = new Bundle();
        bundle.putInt(AppConstant.SURE_ORDER_MODE, AppConstant.FAST_CHECKOUT);
        fragmentSureOrderFromCheckout.setArguments(bundle);
        return fragmentSureOrderFromCheckout;
    }


    @Override
    public int getLayoutId() {
        return R.layout.fragment_sure_order;
    }

    @Override
    public void initData() {
        mUserConfigManager = UserConfigManager.getInstance(mContext);
        Bundle bundle = getArguments();
        if (bundle.containsKey(AppConstant.CONFIRM_ORDER_REPLY_INFO)) {
            mConfirmOrderReplyBean = JsonUtil.getGson().fromJson(bundle.getString(AppConstant.CONFIRM_ORDER_REPLY_INFO), ConfirmOrderReplyBean.class);
        }
        if (bundle.containsKey(AppConstant.SURE_ORDER_MODE)) {
            checkMode = bundle.getInt(AppConstant.SURE_ORDER_MODE);
        }
        EventBus.getDefault().register(this);
    }

    @Override
    public void initView() {

        ntb.setTitleText("确认订单");
        ntb.setLeftImageSrc(R.drawable.iv_back);
        ntb.setOnLeftImageListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                pop();
            }
        });
        tvSelectMember.setText("请选择会员");
        tvSelectTicket.setText("请选择优惠券");

        if (checkMode == AppConstant.NORMAL_CHECKOUT) {
            layoutQuickPay.setVisibility(View.GONE);
            mRecyclerView.setLayoutManager(new LinearLayoutManager(mContext));
            mAdapterGoodsInSureOrder = new AdapterGoodsInSureOrder(R.layout.item_goods_in_sure_order, mConfirmOrderReplyBean.getProductList());
            mRecyclerView.setAdapter(mAdapterGoodsInSureOrder);
            mRecyclerView.addItemDecoration(new HorizontalDividerItemDecoration.Builder(mContext).paintProvider(mAdapterGoodsInSureOrder).build());
        } else {
            layoutQuickPay.setVisibility(View.VISIBLE);
            etPayMoney.postDelayed(new Runnable() {
                @Override
                public void run() {
                    if (etPayMoney != null) {
                        KeyboardUtils.showSoftInput(etPayMoney);
                    }
                }
            }, 100);
        }

        initListener();
        bindData();
    }

    @Override
    public void finishRefresh() {

    }

    @Override
    public void sessionOutOfDate() {

    }

    @Override
    public void requestError(String error) {

    }

    @Override
    public String getPageTag() {
        return FragmentSureOrder.class.getName();
    }

    private void initListener() {
        chkAliPay.setOnCheckedChangeListener(this);
        chkWechatPay.setOnCheckedChangeListener(this);
        chkBalancePay.setOnCheckedChangeListener(this);
        chkCashPay.setOnCheckedChangeListener(this);
        etPayMoney.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

            }

            @Override
            public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
                tvTotalPrice.setText("￥" + charSequence);
                caculateMoney();
            }

            @Override
            public void afterTextChanged(Editable editable) {

            }
        });
    }

    private void bindData() {
        InputFilter[] filters = {new EditInputFilter(), new InputFilter.LengthFilter(9)};
        etPayMoney.setFilters(filters);
        if (checkMode == AppConstant.NORMAL_CHECKOUT) {
            tvTotalPrice.setText("￥" + mConfirmOrderReplyBean.getProductTotalMoney());
            tvDiscount.setText("已优惠： ￥" + mConfirmOrderReplyBean.getProductDiscountMoney());//getTotalDiscount
            mAdapterGoodsInSureOrder.setNewData(mConfirmOrderReplyBean.getProductList());
        } else {
            tvTotalPrice.setText("￥" + 0);
            tvDiscount.setText("已优惠： ￥" + 0);//getTotalDiscount
        }
    }

    private void bindCurMember() {
        mCouponBean = null;
        String name = mChooseMemberBean.getTrueName().replace("#", "");
        if (mChooseMemberBean.getMobileNum() != null) {
            tvSelectMember.setText(name + "(" + mChooseMemberBean.getMobileNum() + ")");
        } else {
            tvSelectMember.setText(name);
        }
        if (TextUtils.isEmpty(mChooseMemberBean.getMemberCode())) {//游客不能余额支付
            chkBalancePay.setChecked(false);
            layoutBalancePay.setEnabled(false);
            chkBalancePay.setEnabled(false);
            chkBalancePay.setClickable(false);
            layoutBalancePay.setBackgroundColor(getResources().getColor(R.color.sg_common_line_bg_dark));
        } else {
            layoutBalancePay.setEnabled(true);
            chkBalancePay.setEnabled(true);
            chkBalancePay.setClickable(true);
            layoutBalancePay.setBackgroundColor(getResources().getColor(R.color.white));
        }
        confirmOrder();
        if (mChooseMemberBean.isHasCoupons()) {
            layoutTicket.setEnabled(true);
            tvSelectTicket.setText("请选择优惠券");
        } else {
            layoutTicket.setEnabled(false);
            tvSelectTicket.setText("无可用优惠券");
        }
        if (checkMode == AppConstant.FAST_CHECKOUT) {
            caculateMoney();
        }
    }

    private void bindCoupon() {
        if (mCouponBean != null) {
            switch (mCouponBean.getTypeCode()) {
                case AppConstant.TYPE_XIANJIN_TICKET:
                    tvSelectTicket.setText("-" + mCouponBean.getMoneyQuota());
                    break;
                case AppConstant.TYPE_MANDI_TICKET:
                    tvSelectTicket.setText("-" + mCouponBean.getDeductQuota());
                    break;
                case AppConstant.TYPE_ZHEKOU_TICKET:
                    tvSelectTicket.setText(mCouponBean.getDiscountQuota() + "折");
                    break;
                case AppConstant.TYPE_HUOQI_TICKET:
                    tvSelectTicket.setText("-" + mCouponBean.getMoneyQuota());
                    break;
                case AppConstant.TYPE_DANPIN_TICKET:
                    tvSelectTicket.setText("-" + mCouponBean.getMoneyQuota());
                    break;
            }
            confirmOrder();
        } else {
            mCouponBean = null;
            tvSelectTicket.setText("请选择优惠券");
        }
        if (checkMode == AppConstant.FAST_CHECKOUT) {
            caculateMoney();
        }
    }


    private void confirmOrder() {
        if (checkMode != AppConstant.FAST_CHECKOUT) {
            sendRequestConfirmBuyOrder(false);
        }
    }

    private void caculateMoney() {
        if (mCouponBean != null) {
            BigDecimal bgDiscount;
            if (mCouponBean.getTypeCode() == AppConstant.TYPE_ZHEKOU_TICKET) {
                bgDiscount = new BigDecimal(mCouponBean.getDiscountQuota());
            } else {
                bgDiscount = new BigDecimal(mCouponBean.getMoneyQuota());
            }
            BigDecimal bgTotalMoney;
            String pureNumber = BizUtil.getPureNumber(etPayMoney.getText().toString());
            if (!TextUtils.isEmpty(pureNumber)) {
                bgTotalMoney = new BigDecimal(pureNumber);
            } else {
                bgTotalMoney = new BigDecimal("0");
            }
            if (mCouponBean.getTypeCode() == AppConstant.TYPE_ZHEKOU_TICKET) {
                BigDecimal all = new BigDecimal(10);
                bgDiscount = bgTotalMoney.multiply(all.subtract(bgDiscount)).divide(all);
            } else {

            }
            if (bgDiscount.compareTo(bgTotalMoney) > 0) {
                tvDiscount.setText("已优惠： ￥" + bgTotalMoney);
                tvTotalPrice.setText("￥" + 0);
            } else {
                tvDiscount.setText("已优惠： ￥" + bgDiscount.setScale(2, BigDecimal.ROUND_HALF_UP));
                tvTotalPrice.setText("￥" + (bgTotalMoney.subtract(bgDiscount)).setScale(2, BigDecimal.ROUND_HALF_UP));
            }
        } else {
            tvDiscount.setText("已优惠： ￥" + 0);//getTotalDiscount
            tvTotalPrice.setText("￥" + etPayMoney.getText().toString());
        }
    }

    private void clearCheck() {
        chkAliPay.setChecked(false);
        chkWechatPay.setChecked(false);
        chkCashPay.setChecked(false);
        chkBalancePay.setChecked(false);
        checkPos = -1;
    }

    private void gotoPay(final CommitOrderReplyBean bean) {
        final FragmentCheckout fragmentCheckout = findFragment(FragmentCheckout.class);
        final Intent intent = new Intent(mContext, PayActivity.class);//https://qr.alipay.com/bax05663gkt4hkscus65602d
        Bundle bundle = new Bundle();
        bundle.putSerializable(AppConstant.COMMIT_REPLY_BEAN, bean);
        bundle.putString(AppConstant.MEMBER_CODE, mChooseMemberBean.getMemberCode());
        if (fragmentCheckout != null) {
            intent.putExtras(bundle);
            popTo(FragmentCheckout.class, false, new Runnable() {
                @Override
                public void run() {
                    fragmentCheckout.startActivity(intent);
                }
            });
        } else {
            bundle.putString(AppConstant.QUICK_PAY_MODE, AppConstant.QUICK_PAY_MODE);
            intent.putExtras(bundle);
            final FragmentMain fragmentMain = findFragment(FragmentMain.class);
            popTo(FragmentMain.class, false, new Runnable() {
                @Override
                public void run() {
                    fragmentMain.startActivity(intent);
                }
            });
        }
    }

    //确认订单信息
    private void sendRequestConfirmBuyOrder(final boolean buyFlag) {
        RequestBody body = getRequestBody();
        if (body != null) {
            SimpleObserverOnNextListener<BaseResponse> listener = new SimpleObserverOnNextListener<BaseResponse>() {
                @Override
                public void onNext(BaseResponse response) {
                    if (response.getReturnCode() == (ResponseCode.RESPONSE_SUCCESS)) {
                        mConfirmOrderReplyBean = (ConfirmOrderReplyBean) JsonUtil.getObject(response.getReturnContent(), ConfirmOrderReplyBean.class);
                        if (buyFlag) {
                            if (checkPos == -1) {
                                ToastUtils.showShort("请选择支付方式");
                                return;
                            }
                            sendRequestCommitBuyOrder();
                        } else {

                        }
                        bindData();
                    } else {
                        ToastUtils.showShort(response.getMessage());
                    }
                }
            };
            SimpleObserverOtherListener errorListener = new SimpleObserverOtherListener() {
                @Override
                public void onSessionOutOfDate() {

                }

                @Override
                public void onError(String error) {
                    ToastUtils.showShort("确认订单失败:" + error);
                }
            };
            ApiMethodGuide.confirmBuyOrder(new SimpleLbObserver(listener, errorListener), body, this, FragmentEvent.DESTROY_VIEW);

        }
    }

    private void sendRequestCommitBuyOrder() {
        RequestBody body = getCommitRequestBody();
        if (body != null) {
            SimpleObserverOnNextListener<BaseResponse> listener = new SimpleObserverOnNextListener<BaseResponse>() {
                @Override
                public void onNext(BaseResponse response) {
                    if (response.getReturnCode() == (ResponseCode.RESPONSE_SUCCESS)) {
                        final CommitOrderReplyBean commitOrderReplyBean = (CommitOrderReplyBean) JsonUtil.getObject(response.getReturnContent(), CommitOrderReplyBean.class);
                        if (commitOrderReplyBean.isPayFlag()) {
                            FragmentCheckout fragmentCheckout = findFragment(FragmentCheckout.class);
                            if (fragmentCheckout != null) {
                                popTo(FragmentCheckout.class, false, new Runnable() {
                                    @Override
                                    public void run() {
                                        start(FragmentPayResult.newInstance(true, commitOrderReplyBean, false));
                                    }
                                });
                            } else {
                                popTo(FragmentMain.class, false, new Runnable() {
                                    @Override
                                    public void run() {
                                        start(FragmentPayResult.newInstance(true, commitOrderReplyBean, true));
                                    }
                                });

                            }
                        } else {
                            commitOrderReplyBean.setPayMode("" + (checkPos));
                            gotoPay(commitOrderReplyBean);
                        }
                    } else {
                        ToastUtils.showShort(response.getMessage());
                    }
                }
            };
            SimpleObserverOtherListener errorListener = new SimpleObserverOtherListener() {
                @Override
                public void onSessionOutOfDate() {

                }

                @Override
                public void onError(String error) {
                    ToastUtils.showShort("提交订单失败:" + error);
                }
            };
            ApiMethodGuide.commitBuyOrder(new SimpleLbObserver(listener, errorListener), body, this, FragmentEvent.DESTROY_VIEW);
        }
    }

    private RequestBody getRequestBody() {
        ConfirmOrderBean bean = new ConfirmOrderBean();
        if (mChooseMemberBean == null) {
            ToastUtils.showShort("请选择会员");
            return null;
        } else {
            if (!TextUtils.isEmpty(mChooseMemberBean.getMemberCode())) {
                bean.setMemberCode(mChooseMemberBean.getMemberCode());
            }
        }
        bean.setProductList(getCommitGoodsList());
        if (mCouponBean != null) {
            bean.setCouponId("" + mCouponBean.getCouponId());
        }
        String json = JsonUtil.getGson().toJson(bean);
        return RequestBody.create(okhttp3.MediaType.parse("application/json;charset=UTF-8"), json);
    }

    private RequestBody getCommitRequestBody() {
        CommitOrderBean bean = new CommitOrderBean();
        if (checkMode == AppConstant.FAST_CHECKOUT) {
            bean.setQuickCash(true);
            String quickMoney = etPayMoney.getText().toString();
            if (!TextUtils.isEmpty(quickMoney)) {
                BigDecimal bGMoney = new BigDecimal(quickMoney);
                BigDecimal bGMax = new BigDecimal("99999999");
                if (bGMoney.compareTo(bGMax) >= 1) {
                    ToastUtils.showShort("输入金额超出限制，请输入小于1亿的金额");
                    return null;
                } else {
                    bean.setQuickCashMoney(quickMoney);
                }
            } else {
                ToastUtils.showShort("请输入金额");
                return null;
            }
        } else {
            bean.setQuickCash(false);
            bean.setProductList(getCommitGoodsList());
        }
        bean.setLeaveMessage(etBeizhu.getText().toString());
        bean.setAppEntranceType("" + AppConstant.ANDROID_ENTRANCE);
        if (mChooseMemberBean == null) {
            ToastUtils.showShort("请选择会员");
            return null;
        } else {
            if (!TextUtils.isEmpty(mChooseMemberBean.getMemberCode())) {
                bean.setMemberCode(mChooseMemberBean.getMemberCode());
            }
        }
        if (mCouponBean != null) {
            bean.setCouponId("" + mCouponBean.getCouponId());
        }
        if (checkPos == -1) {
            ToastUtils.showShort("请选择支付方式");
            return null;
        } else {
            bean.setPayMode("" + checkPos);
        }
        String json = JsonUtil.getGson().toJson(bean);
        return RequestBody.create(okhttp3.MediaType.parse("application/json;charset=UTF-8"), json);
    }


    /**
     * 提交的goods数据
     *
     * @return
     */
    private List<CommitGoodsBean> getCommitGoodsList() {
        List<CommitGoodsBean> list = new ArrayList<>();
        for (GoodsInSureOrderBean bean : mConfirmOrderReplyBean.getProductList()) {
            CommitGoodsBean commitGoodsBean = new CommitGoodsBean();
            commitGoodsBean.setProductCode(bean.getProductCode());
            commitGoodsBean.setProductSum(bean.getProductSum());
            commitGoodsBean.setSkuCode(bean.getSkuCode());
            commitGoodsBean.setDiscountPrice("" + bean.getDiscountPrice());
            list.add(commitGoodsBean);
        }
        return list;
    }

    @Subscribe
    public void selectMember(SelectMemberEvent event) {
        mChooseMemberBean = event.getChooseMemberBean();
        bindCurMember();
    }

    @Subscribe
    public void selectCoupon(SelectCouponEvent event) {
        mCouponBean = event.getCouponBean();
        bindCoupon();
    }

    @OnClick(R.id.rl_ali_pay)
    void alipay() {
        if (chkAliPay.isChecked()) {
            chkAliPay.setChecked(false);
        } else {
            clearCheck();
            chkAliPay.setChecked(true);
            checkPos = AppConstant.PAY_TYPE_ALIPAY;
        }
    }

    @OnClick(R.id.rl_wechat_pay)
    void wechatPay() {
        if (chkWechatPay.isChecked()) {
            chkWechatPay.setChecked(false);
        } else {
            clearCheck();
            chkWechatPay.setChecked(true);
            checkPos = AppConstant.PAY_TYPE_WECHAT_PAY;
        }
    }

    @OnClick(R.id.rl_cash_pay)
    void cashPay() {
        if (chkCashPay.isChecked()) {
            chkCashPay.setChecked(false);
        } else {
            clearCheck();
            chkCashPay.setChecked(true);
            checkPos = AppConstant.PAY_TYPE_CASH_PAY;
        }
    }

    @OnClick(R.id.rl_balance_pay)
    void balancePay() {
        if (chkBalancePay.isChecked()) {
            chkBalancePay.setChecked(false);
        } else {
            clearCheck();
            chkBalancePay.setChecked(true);
            checkPos = AppConstant.PAY_TYPE_BALANCE_PAY;
        }
    }

    @OnClick(R.id.layout_member)
    void onMemberClick() {
        KeyboardUtils.hideSoftInput(etPayMoney);
        start(FragmentSelectMember.newInstance("" + checkMode));
    }

    @OnClick(R.id.layout_ticket)
    void ticketClick() {
        if (mChooseMemberBean != null) {
            start(FragmentSelectCoupon.newInstance(mChooseMemberBean.getMemberCode(), "" + checkMode));
        } else {
            ToastUtils.showShort("请先选择会员");
        }
    }

    @OnClick(R.id.tv_do_order)
    void doOrder() {
        if (!ClickUtil.isFastDoubleClick()) {
            if (checkMode != AppConstant.FAST_CHECKOUT) {
                sendRequestConfirmBuyOrder(true);
            } else {
                sendRequestCommitBuyOrder();
            }
        }
    }


    @Override
    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
        clearCheck();
        if (isChecked) {
            buttonView.setChecked(isChecked);
            if (buttonView.getId() == R.id.chk_ali_pay) {
                checkPos = AppConstant.PAY_TYPE_ALIPAY;
            } else if (buttonView.getId() == R.id.chk_wechat_pay) {
                checkPos = AppConstant.PAY_TYPE_WECHAT_PAY;
            } else if (buttonView.getId() == R.id.chk_cash_pay) {
                checkPos = AppConstant.PAY_TYPE_CASH_PAY;
            } else if (buttonView.getId() == R.id.chk_balance_pay) {
                checkPos = AppConstant.PAY_TYPE_BALANCE_PAY;
            }
        }
    }

    @Override
    public void onDestroyView() {
        EventBus.getDefault().unregister(this);
        super.onDestroyView();
    }

}
